<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>自定义指令</title>
</head>
<body>
  <script>
    // 自定义指令
    /**
     * //模拟 v-show
     * //使用
     * <div v-onShow='flag'>1213</div>
       //全局的
      Vue.directive('onShow', {
        inserted: function (el) {
          el.style.display = a.value ? 'block' : 'none'
        }
      })
      export default {
        directives: { //局部自定义指令
          onShow: { 
            // 指令的定义
            inserted: function (el,a) {
              el.style.display = a.value ? 'block' : 'none'
            }
          }
        },
        data() {
          return {
            num:1,
            flag:false
          };
        },
      };
    **/
  </script>
</body>
</html>